﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Logic.aspx.cs" Inherits="MediaMonitor.Logic" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
     <script src="<%=Utility.AppPath%>/js/jquery-1.2.6.min.js" type="text/javascript"></script>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager runat="server" ID="sm"></asp:ScriptManager>
         <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Label runat="server" ID="lblUpdate"></asp:Label>
 </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="cmdBind" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        <asp:Button ID="cmdBind" runat="server" Text="Bind Some Data"  />
    </div>
    </form>
    <script>
        function showMyDialog() {
            var val = $('#<%= lblUpdate.ClientID %>').text();
            val = val + 'a';
            $('#<%= lblUpdate.ClientID %>').text(val);
            
        }
        $('#<%= cmdBind.ClientID %>').click(function () {
            updte();
            setInterval(function () { updte2() }, 10000);
        });
        function updte() {
            $.ajax({
                type: "POST",
                url: "Logic.aspx/SendMessage",
                data: "{}",
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("Request: " + XMLHttpRequest.toString() + "\n\nStatus: " + textStatus + "\n\nError: " + errorThrown);
                },
                success: function (result) {
                    val = $('#<%= lblUpdate.ClientID %>').text();
                    $('#<%= lblUpdate.ClientID %>').text(val+'a');
                }
            });

        }
        function updte2() {
            $.ajax({
                type: "POST",
                url: "Logic.aspx/Callrandamly",
                data: "{message: '1'}",
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("Request: " + XMLHttpRequest.toString() + "\n\nStatus: " + textStatus + "\n\nError: " + errorThrown);
                },
                success: function (result) {
                    val = $('#<%= lblUpdate.ClientID %>').text();
                    $('#<%= lblUpdate.ClientID %>').text(val + result.d.toString());

                    // rowinserted / totalrow * 100 = percentage
                    // 
                }
            });
        }
</script>
</body>
</html>
